﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

/// <summary>
/// Link 的摘要说明
/// </summary>
public class Link
{
    private int id;

    public int Id
    {
        get { return id; }
        set { id = value; }
    }
    private string linkname;

    public string Linkname
    {
        get { return linkname; }
        set { linkname = value; }
    }
    private string pic;

    public string Pic
    {
        get { return pic; }
        set { pic = value; }
    }
    private string url;

    public string Url
    {
        get { return url; }
        set { url = value; }
    }

    private string type;

    public string Type
    {
        get { return type; }
        set { type = value; }
    }


    public const string ADDLINK = "insert into link values(@linkname,@pic,@url,@type)";

    public const string DELLINK = "delete from link where id=@id";

    public const string GETALLLINK = "select * from link";

    public const string UPDATELINK = "update link set linkname=@linkname,pic=@pic,@url=@url,type=@type where id=@id";

    public void AddLink(Link l)
    {
        SqlHelper.ExecuteNonQuery(ADDLINK,
            new SqlParameter("@linkname", l.Linkname),
            new SqlParameter("@pic", l.Pic),
            new SqlParameter("@url", l.Url),
            new SqlParameter("@type", l.Type));
    }

    public void DelLink(int id)
    {
        SqlHelper.ExecuteNonQuery(DELLINK,
            new SqlParameter("@id", id));
    }

    public void UpdateLink(Link l)
    {
        SqlHelper.ExecuteNonQuery(ADDLINK,
            new SqlParameter("@linkname", l.Linkname),
            new SqlParameter("@pic", l.Pic),
            new SqlParameter("@url", l.Url),
            new SqlParameter("@type", l.Type),
            new SqlParameter("@id", l.Id));
    }

    public DataTable GetAllLink()
    {
        DataTable dt = new DataTable();
        SqlHelper.FillDataTable(GETALLLINK, dt);
        return dt;
    }



}
